package com.xhs.miniapp.bean;

import com.google.gson.annotations.SerializedName;
import com.xhs.miniapp.json.XhsMaGsonBuilder;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * <pre>
 * code换取session_key接口的响应
 * 文档地址：https://miniapp.xiaohongshu.com/doc/DC414670
 *
 * 微信返回报文：
 * {
 *     "data":{
 *         "openid":"string",
 *         "session_key":"string"
 *     },
 *     "success":true,
 *     "msg":"string",
 *     "code":0
 * }
 * </pre>
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class XhsMaJscode2SessionResult implements Serializable {
  private static final long serialVersionUID = -1060216618475607933L;

  @SerializedName("session_key")
  private String sessionKey;

  @SerializedName("openid")
  private String openid;

  public static XhsMaJscode2SessionResult fromJson(String json) {
    return XhsMaGsonBuilder.create().fromJson(json, XhsMaJscode2SessionResult.class);
  }

}
